<?php include "../public/header.php";?>
<?php include "../public/header_edit.php";?>
<link rel="stylesheet" type="text/css" href="/static/component/laytp/module/cityPicker/city-picker.css">

<body id="optPage">
<form class="layui-form layui-form-pane" id="commentForm">
    <div class="page-title"><div class="page-title-con"><span>投标</span><div class="move_title"></div><?php include "../public/sub.php";?></div></div>
    <div class="main-container">
        <div class="block-generic">
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="edittits"><span>基本信息</span></div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <input type="text" id="name" disabled autocomplete="off" class="layui-input disabled">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">投标时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="tou_dt" id="tou_dt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymdhi">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">投标金额(元)</label>
                        <div class="layui-input-block">
                            <input type="text" id="tou_fee" name="tou_fee" placeholder="请输入" clearable autocomplete="off" class="layui-input moneyinput">
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">开标时间</label>
                        <div class="layui-input-block">
                            <input type="text" name="kaidt" id="kaidt" readonly placeholder="请选择" clearable  autocomplete="off" class="layui-input bdate_ymdhi">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">开标方式</label>
                        <div class="layui-input-block">
                            <select id="tou_kaitype" name="tou_kaitype" lay-filter="tou_kaitype"></select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md6">
                        <label class="layui-form-label">开标地点</label>
                        <div class="layui-input-block">
                            <input type="text" name="tou_kaiaddr" id="tou_kaiaddr" placeholder="请输入" clearable  autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-col-md6">
                        <label class="layui-form-label">开标人</label>
                        <div class="layui-input-block">
                            <div class="tanxian">
                                <div class="tanxianclick" onclick="openPage('../public/choose_userpart.php?dom=tou_kaier&type=user&single=1', '770px', '490px');"></div>
                                <div class="tanxiannei" id="tou_kaier"></div>
                            </div>
                            <div class="tancheckdiv"><div class="tancheck" onclick="openPage('../public/choose_userpart.php?dom=tou_kaier&type=user&single=1', '770px', '490px');"><i class="layui-icon layui-icon-search"></i></div></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item height_auto">
                <div class="layui-row layui-col-space10">
                    <div class="layui-col-md12">
                        <label class="layui-form-label label_textarea">投标说明</label>
                        <div class="layui-input-block">
                            <textarea id="tou_explain" name="tou_explain" placeholder="请输入" class="layui-textarea"></textarea>
                        </div>
                    </div>
                </div>
            </div>

            <?php include '../public/upinfo.php'?>
        </div>

    </div>
</form>
<script>
    var param_id = getQueryVariable('id') || 0;


    layui.use(['laytp', 'form'], function() {
        var form = layui.form, layer = layui.layer;
        render_input_attr();

        facade.ajax({type: 'get', url: ask_bid_tou,data:{id:param_id}}).done(function(res){
            if (res.code === 2000) {
                var data = res.data.data;

                $('#name').val(data.name);
                $('#kaidt').val(data.kaidt);
                $('#tou_dt').val(data.tou_dt);
                $('#tou_fee').val(data.tou_fee);
                $('#tou_kaiaddr').val(data.tou_kaiaddr);
                $('#tou_explain').val(data.tou_explain);


                var tou_kaitype_str = '<option value="">请选择</option>';
                var tou_kaitype = res.data.tou_kaitype;
                for (var key in tou_kaitype){
                    if(data.tou_kaitype == key){
                        tou_kaitype_str += '<option value="'+tou_kaitype[key]+'" selected>'+tou_kaitype[key]+'</option>';
                    }else{
                        tou_kaitype_str += '<option value="'+tou_kaitype[key]+'">'+tou_kaitype[key]+'</option>';
                    }
                }
                $("#tou_kaitype").html(tou_kaitype_str);


                if(data.tou_kaier_info.length > 0){
                    tan_tags_init('#tou_kaier', data.tou_kaier_info);
                }


                public_upload_file_load('upload_files', res.data.files);
                render_date();
                render_from();
                initParseMoney();
            }
        });


        form.on('submit(add)', function(data){
            data.field.tou_kaier = tan_tags_getvalue("#tou_kaier", 'user');
            var validRes = $("#commentForm").valid();
            if(!validRes){return false;}

            data = parseMoney(data);
            data.field.id = param_id;
            data.field.files = public_upload_file_value('upload_files');
            facade.ajax({url: ask_bid_tou, data:data.field}).done(function(res){
                if (res.code === 2000) {
                    dataPostTimeOut();
                }
            });

            return false;
        });

    });

</script>
</body>
</html>
